package ute.mvc.controller.home;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import ute.mvc.util.GMailUtil;

@Controller
@RequestMapping(value = "/contact")
public class ContactController {

	@RequestMapping(method = RequestMethod.GET)
	public String getContact(Model model) {
		String html = "Load contact information from database (about written by CKEditor in html form) ContactController.java";

		model.addAttribute("html", html);
		return "contact";
	}

	@RequestMapping(method = RequestMethod.POST)
	public String setContact(
			@RequestParam(value = "txtName", required = false) String name,
			@RequestParam(value = "txtEmail", required = false) String email,
			@RequestParam(value = "txtMessage", required = false) String message) {
		// Send email
		GMailUtil.send("support@gmail.com", "Customer", "Name: " + name
				+ "; Email: " + email + "; Message: " + message);
		return "contact";
	}
}
